clear

for i = 1:1:10000   % Creates 5kHz cosine
    send(i) = cos(0.0005*i*2*pi);
    recieve1(i) = cos(0.0005*i*2*pi - 0.5);
    recieve2(i) = cos(0.0005*i*2*pi - 0.2);
    time(i) = i/(10e3);
end

figure(1)
plot(time,send,time,recieve1,time,recieve2)

d  = fdesign.lowpass('Fp,Fst,Ap,Ast',0.001,0.002,0.1,1e-4,'linear');
Hd = design(d); % Uses the FIR window method
yideal = filtfilt(Hd.Numerator,1,send); %filtfilt uses zero-phase
    
figure(2)
plot(time,yideal)